package com.example.fitnessservice.module.dao.courseMapper;

import org.apache.ibatis.annotations.*;

/**
 * @author feng
 * @version 1.0
 * @&#064;description: TODO
 * @&#064;date 2022/11/24 10:58
 */
@Mapper
public interface UserCourseMapper {
    /*
    添加课程，默认课程状态为2
     */

    @Insert("insert into user_course (user_id,course_id,course_status,course_camp_if)values(#{userId},#{courseId},2,#{courseCampIf})")
    Integer join(@Param("userId") Integer userId, @Param("courseId") Integer courseId, @Param("courseCampIf") Integer courseCampIf);

    /*
    选课状态，
    1正常选课
    6已退课

     */
    @Delete("update user_course set course_status=6 where user_id=#{userId} and course_id=#{courseId} and course_camp_if=#{courseCampIf}")
    Integer cancelCourse(@Param("userId") Integer userId, @Param("courseId") Integer courseId, @Param("courseCampIf") Integer courseCampIf);

    @Update("update user_course set course_status=#{status} where user_id=#{userId} and course_id=#{courseId} and course_camp_if=1")
    Integer updateCourseStatus(@Param("courseId") Integer campCourseId, @Param("userId") Integer userId, @Param("status") Integer status);

    @Update("update user_course set course_status=4 where course_status=2 and course_id=#{courseId} and course_camp_if=#{campIf}")
    Integer takeCourse(@Param("courseId") Integer courseId, @Param("campIf") Integer courseCampIff);

    @Update("update user_course set course_status=1 where course_status=4 and course_id=#{courseId} and course_camp_if=#{campIf}")
    Integer finishiCourse(@Param("courseId") Integer courseId, @Param("campIf") Integer courseCampIf);
    @Select("select count(*) from user_course where course_status=1 and course_id=#{courseId} and course_camp_if=#{campIf}=#{campIf}")
    Integer getNormalNum(@Param("courseId") Integer courseId, @Param("campIf") Integer courseCampIf);
}
